package com.rpp.utils;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author rpp
 * @Date 2020/6/29 11:22 下午
 */
public class AopUtils {

    /**
     * 注解的缓存
     */
    private static Map<String, Class<?>> map = new HashMap<>();

    /**
     * 通过类名和方法名判断是否有目标注解
     *
     * @param key
     * @return annotationClass
     */
    public static Boolean isAnnotationPresent(String key, Class<? extends Annotation> annotationClass) {
        Class<?> aClass = map.get(key);
        if (null == aClass) {
            return false;
        }
        return aClass.equals(annotationClass);
    }

    /**
     * 添加注解缓存
     *
     * @param key
     * @param annotationClass
     */
    public static void addAnnotation(String key, Class<? extends Annotation> annotationClass) {
        map.put(key, annotationClass);
    }
}
